import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
// elementUI自动导入所需 start
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
// elementUI自动导入所需 end
import { vitePluginFakeServer } from "vite-plugin-fake-server"; //vite集成的类似mock的插件
import { lazyImport, VxeResolver } from "vite-plugin-lazy-import"; //
import UnoCss from "unocss/vite";
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    UnoCss(),
    // elementUI自动导入所需 start
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    lazyImport({
      resolvers: [
        VxeResolver({
          libraryName: "vxe-table",
        }),
      ],
    }),
    // elementUI自动导入所需 end
    vitePluginFakeServer({
      logger: false,
      include: "mock",
      infixName: false,
      enableProd: true,
    }), //vite集成的类似mock的插件
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        api: "modern-compiler", // or 'modern'  // Vite 使用 SASS 的现代 API
      },
    },
  },
});
